﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ATSBLL;

public partial class PIMTest_PIMTestDTCategory: System.Web.UI.Page
{

    private PIMTest Ptest;

    public PIMTest_PIMTestDTCategory()
    {
        Ptest = new PIMTest();
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
     

    public void BindTests()
    {
        if (!string.IsNullOrEmpty(tbStart.Value.ToString()) && !string.IsNullOrEmpty(tbEnd.Value.ToString()))
        {
            DateTime dtStart = DateTime.Parse(tbStart.Value.Trim());
            DateTime dtEnd = DateTime.Parse(tbEnd.Value.Trim());
            GridView1.DataSource = Ptest.GetTestsbyDT(dtStart, dtEnd);
            GridView1.DataBind();
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                if (GridView1.Rows[i].Cells[8].Text == "Fail")
                    GridView1.Rows[i].Cells[8].ForeColor = System.Drawing.Color.Red;
            }
        }
    }

    protected void butSelect_Click(object sender, EventArgs e)
    {
        BindTests();
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindTests();
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string productSN = GridView1.SelectedDataKey["ProductSN"].ToString();
        Session["pIMRecordTime"] = Convert.ToDateTime(GridView1.SelectedDataKey["PIMRecordTime"]);//DateTime pIMRecordTime = Convert.ToDateTime(GridView1.SelectedDataKey["PIMRecordTime"]);"&pIMRecordTime=" + pIMRecordTime + 
        string productTypeID = GridView1.SelectedDataKey["ProductTypeID"].ToString();
        string userID = GridView1.SelectedDataKey["UserID"].ToString();
        string userID2 = GridView1.SelectedDataKey["UserID2"].ToString();
        string pIMENAID = GridView1.SelectedDataKey["PIM_ENAID"].ToString();
        string pIMPass = GridView1.SelectedDataKey["PIMPass"].ToString();

        Response.Redirect("../PIMTest/PIMTestDetails/ViewPIMTestItem.aspx?ProductSN=" + productSN + "&ProductTypeID=" + productTypeID + "&UserID=" + userID + "&PIM_ENAID=" + pIMENAID + "&PIMPass=" + pIMPass + ""); 
      
    }
}
